<template>
  <h3>全局使用axios</h3>
  <button @click="add">请求数据</button>
  {{ list }}
</template>

<script setup>
import { ref, getCurrentInstance } from 'vue'

const { proxy } = getCurrentInstance();
const list = ref([]);
const add = () => {
  proxy.$axios.get('http://www.phonegap100.com/appapi.php?a=getPortalList',
    { params: { catid: 20, page: 1 } }
  )
    .then(res => {
      console.log(res);
      list.value = res.data.result;

    }).catch(error => {
      console.log(error)
    })
}
</script>